package com.itheima;

import com.itheima.pojo.Goods;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.test.context.junit4.SpringRunner;


/*
 * 创建索引库
 * 配置映射
* */
@RunWith(SpringRunner.class)
@SpringBootTest
public class Demo01CreateIndexAndPutMapping {

	/*
	* SpringData中，针对每个持久层封装框架，都提供一个模板对象
	*
	* ElasticsearchTemplate：将对场景的持久层操作，封装到模板类中
	* */
	@Autowired
	private ElasticsearchTemplate elasticsearchTemplate;


	/*
	 * 创建索引库
	 * 配置映射
	 * */
	@Test
	public void createIndexAndPutMapping() {
		elasticsearchTemplate.createIndex(Goods.class);
		elasticsearchTemplate.putMapping(Goods.class);
	}

}
